package threading;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-04-23
 * Time: 22:43
 */
public class ThreadDemo11 {
    volatile public static int flag = 0;

    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
           while(flag == 0) {
               //空着 如果是0一直循环
           }
            System.out.println("循环结束！t1结束~");
        });

        Thread t2 = new Thread(()->{
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入一个整数：");
            flag = sc.nextInt();
        });

        t1.start();
        t2.start();
    }
}
